<?php

class Application_Model_Transalist extends Application_Model_DomainObject {

      protected $_id;
      protected $_count;
      protected $_num;
      protected $_listId;

      public static function getFilter($name, $pagesize, $pageindex) {
            $where = array();
            if ($name != null) {
                  $where[" listId = "] = $name;
            }
            return Application_Model_Transalist::getDao()->queryPage($where, 'id desc', $pagesize, $pageindex);
      }

      public static function getbyid($id, $pagesize, $pageindex) {
            $where = array();
            if ($id != null) {
                  $where[" id = "] = $id;
            }
            return Application_Model_Transalist::getDao()->queryPage($where, 'id desc', $pagesize, $pageindex);
      }

      public static function getbycount($count, $pagesize, $pageindex) {
            $where[" count = "] = $count;
            return Application_Model_Transalist::getDao()->queryPage($where, 'id desc', $pagesize, $pageindex);
      }

      public static function getbyNum($transationCS) {
            $where = array();
            $where[" num = "] = $transationCS;

            return Application_Model_Transalist::getDao()->queryPage($where);
      }

      public static function getbydingdan($transationCS) {
            $where = array();
            $where[" num = "] = $transationCS;

            return Application_Model_Transalist::getDao()->queryOne($where);
      }

      public static function getPageFilter($quick, $pagesize, $pageindex) {
            $where = array();
            if ($quick != "") {
                  $uwhere[" name like "] = "%" . $quick . "%";
                  $shipItem = Application_Model_shipType::getDao()->queryAll($uwhere);
                  $shipId = "";
                  foreach ($shipItem as $shipVal) {
                        $shipId.= "'" . $shipVal->id . "',";
                  }
                  $where[" listId in "] = "(" . $shipId . "0)";
                  $where[" or num = "] = $quick;
            }
//            var_dump($where);exit;
            return self::getDao()->queryPage($where, " id asc ", $pagesize, $pageindex);
      }

      public function getTransaDate() {
            return Application_Model_Transa::load($this->_count);
      }

      public function getShipType() {
            return Application_Model_Transa::getshiptype($this->_listId);
      }

}
